package com.css.dzj.dzjap.common.menu;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.css.aq.server.service.BaseService;
import com.css.dzj.dzjap.common.util.HttpClientUtil;
import com.css.dzj.dzjap.common.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/dict")
@PropertySource(value = "classpath:base.properties")
public class GetDictController {
    /* @Value("${BASE_URL}")
      private  String BASE_URL;
      @Value("${BASE_API_DICT}")
      private  String BASE_API_DICT;*/
    @Autowired
    BaseService baseService;
    @PostMapping("/getdict/{category}")
    public R getDict(@PathVariable String category){
        /* String url=BASE_URL+BASE_API_DICT;*/
        /*   String data= HttpClientUtil.doGet(url+category);*/
        Map map= baseService.listByCategory(category);
        String data= JSON.toJSONString(map);
        JSONObject jsonObject=JSONObject.parseObject(data);
        System.out.println(jsonObject);
        return R.ok().put("data",jsonObject);
    }
}
